package com.wf.test_quartz_demo.job;

import cn.hutool.core.date.DateUtil;

import cn.hutool.extra.spring.SpringUtil;
import com.wf.test_quartz_demo.bean.CommonResult;
import com.wf.test_quartz_demo.bean.QuartzJobVO;
import com.wf.test_quartz_demo.bean.RecordsParam;
import com.wf.test_quartz_demo.mapper.QuartzJobInfoMapper;
import com.wf.test_quartz_demo.service.impl.TestQuartzJobServiceImpl;

import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;

import javax.annotation.Resource;
import java.util.List;


/**
 * @Description: 任务一
 */
@Slf4j
public class MyJobOne implements Job {

    @Override
    public void execute(JobExecutionContext jobExecutionContext) {
        //获取传递过来的参数
        JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();
        //此处无法通过spring获取mapper
        QuartzJobInfoMapper quartzJobMapper = SpringUtil.getBean("quartzJobInfoMapper");

        //查询任务列表
        List<QuartzJobVO> result = quartzJobMapper.getJobAndTriggerDetails(new RecordsParam());
        log.info("任务列表总数为：{}" , result.size());
        log.info("MyJobOne执行时间--->: {}" , DateUtil.now());
        jobDataMap.forEach((key,value)->{
            log.info("MyJobOne接收到的参数Key---value--->{}--{}",key,value);

        });

    }

}
